//
//  ReceivedExpressCell.m
//  TengyunStation
//
//  Created by Johnny on 15/8/28.
//  Copyright (c) 2015年 xingrong. All rights reserved.
//

#import "ReceivedExpressCell.h"
#import "ReceivedExpress.h"
#import "UIImageView+WebCache.h"
#import "SocketMethod.h"
#import "TSHeader.h"

@implementation ReceivedExpressCell

- (void)awakeFromNib {
    // Initialization code
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(0, 63.5, 320, 0.5)];
    line.backgroundColor = LineColor;
    [self addSubview:line];
    _companyImageView.layer.cornerRadius = 4;
    _companyImageView.clipsToBounds = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)reloadReceivedExpressCellWithReceivedExpress:(ReceivedExpress *)express {
    NSString *companyUrl = [express.expressCompanyLogoUrl stringByReplacingOccurrencesOfString:@"\\" withString:@"/"];
    NSURL *logoUrl = [NSURL URLWithString:companyUrl];
    [_companyImageView sd_setImageWithURL:logoUrl placeholderImage:[UIImage imageNamed:@"yijskd_logo_bg"]];
    _companyNameLabel.text = express.expressCompanyName;
    _expressIdLabel.text = [NSString stringWithFormat:@"运单号:%@",express.expressId];
    if (express.isOverdue == 0 || express.isOverdue == 1) {
        _expressTypeLabel.text = [SocketMethod expressType:express.expressType];
    } else if (express.isOverdue == 2) {
        _expressTypeLabel.text = [NSString stringWithFormat:@"%@(逾期%@天)",[SocketMethod expressType:express.expressType],express.remark];
    }
    if (express.smsSendType == 0 || express.smsSendType == 1) {//发送中
        _smsImageView.image = [UIImage imageNamed:@"sms_wait"];
        self.backgroundColor = [UIColor whiteColor];
    } else if (express.smsSendType == 3) {//发送成功
        _smsImageView.image = [UIImage imageNamed:@"sms_success"];
    } else if (express.smsSendType == 2) {//发送失败
        _smsImageView.image = [UIImage imageNamed:@"sms_false"];
    }
    if (([express.expressType isEqualToString:@"0002"] || [express.expressType isEqualToString:@"0005"] || [express.expressType isEqualToString:@"0006"] || [express.expressType isEqualToString:@"0031"]) && express.smsSendType == 2) {
        self.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
    } else {
        self.backgroundColor = [UIColor whiteColor];
    }
}

@end
